<!-- 商品详情弹窗 -->
<template>
            <a-form
                    ref="form3"
                    class="ele-form-detail"
                    :model="commodityModalApp.commodity"
                    :label-col="{md: {span: 2}, sm: {span: 4}, xs: {span: 6}}"
                    :wrapper-col="{md: {span: 22}, sm: {span: 20}, xs: {span: 18}}">
                <a-descriptions :title="commodityModalApp.title" bordered>
                                    <a-descriptions-item label="标识">
                        {{ commodityModalApp.commodity.Eid }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="创建人">
                        {{ commodityModalApp.commodity.creatorName }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="名称">
                        {{ commodityModalApp.commodity.name }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="描述信息">
                        {{ commodityModalApp.commodity.description }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="商品类别">
                        {{ commodityModalApp.commodity.category }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="用户">
                        {{ commodityModalApp.commodity.userId }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="店铺">
                        {{ commodityModalApp.commodity.shopId }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="状态">
                        {{ commodityModalApp.commodity.status }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="创建人ID">
                        {{ commodityModalApp.commodity.creatorId }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="备注">
                        {{ commodityModalApp.commodity.remark }}
                    </a-descriptions-item>
                                    <a-descriptions-item label="创建时间">
                        {{ commodityModalApp.commodity.createDatetime }}
                    </a-descriptions-item>
                                </a-descriptions>
            </a-form>
</template>

<script>
    import {defineComponent, reactive, onMounted, inject} from "vue";
    import {useRoute} from "vue-router"
    import {CommodityService} from "@/views/mall/good/commodity/commodityService";

    export default defineComponent({
        setup() {
            const route = useRoute();
            let routeId = route.params.id;
            let commodityListApp = inject('commodityListApp', reactive({}));
            const commodityModalApp = reactive({id: null, commodity: {}, display: false});

            onMounted(() => {
                    commodityModalApp.commodity = {};
                if (routeId) {
                        commodityModalApp.id = routeId;
                } else if (commodityListApp.viewModalShowing) {
                        commodityModalApp.id = commodityListApp.currentId;
                        commodityModalApp.display = true;
                }
                if (commodityModalApp.id) {
                    getInfo(commodityModalApp.id);
                }
            })

            const getInfo = (id) => {
                    CommodityService.findCommodity(id).then((res) => {
                            commodityModalApp.commodity = res.data;
                            commodityModalApp.title = "查看 " + commodityModalApp.commodity.name;
                })
            }

            return {
                    commodityModalApp,
                routeId,
                getInfo,
            }
        }
    })
</script>

<style scoped>
</style>

